package activities;

import utils.AppPreferences;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Menu;
import android.widget.ProgressBar;

import com.bugsense.trace.BugSenseHandler;
import com.mga.wheelcommunity.R;

public class HeadbandActivity extends Activity {

	ProgressBar progressBar;
	long timerLenght = 3000;
	long interval = 400;
	int progressValue = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		BugSenseHandler.initAndStartSession(this, "ce2ba067");
		setContentView(R.layout.headband);

		progressBar = (ProgressBar) findViewById(R.id.progressBar);

		final Class className = 
				((AppPreferences.getTokenValue(this) != null) 
						&& (AppPreferences.getUserIdValue(this) != null)) 
						? DrawerActivity.class
						: LoginActivity.class;

		new CountDownTimer(timerLenght, interval) {

			@Override
			public void onTick(long millisUntilFinished) {

			}

			@Override
			public void onFinish() {
				Intent i = new Intent();
				i.setClass(HeadbandActivity.this, className);
				startActivity(i);
				finish();
			}
		}.start();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.headband, menu);
		return true;
	}

}
